String inputString = "";         // a string to hold incoming data
boolean stringComplete = false;  // whether the string is complete

void setup()  
{
  Serial1.begin(9600);
  Serial1.println("Malyon HA Lighting System Booting....");
}

void loop()                     // run over and over again
{

 if (stringComplete) {
Serial1.println(inputString);
   //     Serial.println(inputString); 
//  int i, count; 
//  for (i=0, count=0; inputString[i]; i++) 
//    count += (inputString[i] == ','); 
//
//  String newData[count];
//
//  for(int i =0; i < count;i++){
//    int firstpos = inputString.indexOf(",");
//    newData[i] = inputString.substring(0,firstpos);
//    inputString = inputString.substring(firstpos+1,inputString.length());
//  }


//  steers.write(convint(newData[0]));
//  drives.write(convint(newData[1]));
     inputString = "";
     stringComplete = false;
    
      }
     // clear the string:

}

void serialEvent1() {
   while (Serial1.available()) {
     // get the new byte:
     char inChar = (char)Serial1.read(); 
     // add it to the inputString:
     
     // if the incoming character is a newline, set a flag
     // so the main loop can do something about it:
     if (inChar == '\n') {
         stringComplete = true;
     } else{
     inputString += inChar;
     }
   }
   
   

}
long convint(String Data){
  char carray2[Data.length() +1];
  Data.toCharArray(carray2,sizeof(carray2));
  return atol(carray2); 
}
